package com.ruoyi.base.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.base.domain.ClientUser;
import com.ruoyi.base.service.ClientUserService;
import com.ruoyi.base.mapper.ClientUserMapper;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author Administrator
* @description 针对表【client_user】的数据库操作Service实现
* @createDate 2025-06-24 10:38:45
*/
@Service
public class ClientUserServiceImpl extends ServiceImpl<ClientUserMapper, ClientUser>
    implements ClientUserService{
    @Autowired
    private ClientUserMapper clientUserMapper;

    @Override
    public ClientUser getByOpenId(String openid) {
        return lambdaQuery().eq(ClientUser::getOpenId, openid).one();
    }

    /**
     * 查询小程序用户
     *
     * @param id 小程序用户主键
     * @return 小程序用户
     */
    @Override
    public ClientUser selectClientUserById(Long id)
    {
        return clientUserMapper.selectClientUserById(id);
    }

    /**
     * 查询小程序用户列表
     *
     * @param clientUser 小程序用户
     * @return 小程序用户
     */
    @Override
    public List<ClientUser> selectClientUserList(ClientUser clientUser)
    {
        return clientUserMapper.selectClientUserList(clientUser);
    }

    /**
     * 新增小程序用户
     *
     * @param clientUser 小程序用户
     * @return 结果
     */
    @Override
    public int insertClientUser(ClientUser clientUser)
    {
        clientUser.setCreateTime(DateUtils.getNowDate());
        return clientUserMapper.insertClientUser(clientUser);
    }

    /**
     * 修改小程序用户
     *
     * @param clientUser 小程序用户
     * @return 结果
     */
    @Override
    public int updateClientUser(ClientUser clientUser)
    {
        clientUser.setUpdateTime(DateUtils.getNowDate());
        return clientUserMapper.updateClientUser(clientUser);
    }

    /**
     * 批量删除小程序用户
     *
     * @param ids 需要删除的小程序用户主键
     * @return 结果
     */
    @Override
    public int deleteClientUserByIds(Long[] ids)
    {
        return clientUserMapper.deleteClientUserByIds(ids);
    }

    /**
     * 删除小程序用户信息
     *
     * @param id 小程序用户主键
     * @return 结果
     */
    @Override
    public int deleteClientUserById(Long id)
    {
        return clientUserMapper.deleteClientUserById(id);
    }

}




